********************************************************************************
*																				*
*					IZA Covid Regressions + Visualization						*
*								Replication										*
*																				*
********************************************************************************
	
* 	Note: 	
*				The dofile does not require setting up a current directory
	
*				Directly executing the dofile after extracting contents from main ZIP
*				file will display all results
	
*				Prepared using: Stata/SE 17.0 for Windows (64-bit) (Revision 6 Apr 2022)


* Description:
*				The provided code reproduces the figure in blog.

*				The code is ordered in the same manner as numbers appear in text.
*				To make it easy to read, each code block is numbered and header
*				is provided to match with that within the blog text.

	
********************************************************************************		

* 								Visualization 	

********************************************************************************

		use "./Data/match_level_public.dta", clear
	
		keep if 	monthly_date >= td(01feb2019) 
		
		collapse 	(mean) planinterview_100 female_js, by(memid monthly_date)
		
		preserve
		
	** Generating date variable
		clear
		set 		obs 48
		
		local 	i = 0
		local 	cmd generate
		forvalues month = 1/12{
		forvalues year = 2019(1)2022{
		`cmd' datestr = "1/`month'/`year'" in `=`++i''
		local cmd replace
				}
			}
			
		gen 	   double monthly_date = date( datestr, "DMY")
		keep if    monthly_date >= td(01feb2019) 
		keep 	   monthly_date
		
		tempfile   months
		save 	   `months'
		
		restore

		statsby mean = r(mean) lb = r(lb) ub = r(ub), by(monthly_date female_js) clear: ci means planinterview_100
		format %9.2f mean
		
		joinby monthly_date using `months', unmatched(both)
		expand 2 if _merge == 2, gen(identity)
		replace female_js = identity if missing(female_js)

		
		generate mdate1 = monthly_date - 10
		generate mdate2 = monthly_date + 10
		sort monthly_date
		
		
		keep if monthly_date >= 21581
		generate srno = _n
		
		generate date = mofd(monthly_date)

		
		#delimit ;
		twoway 
				(scatteri 0 721 0 751 4.25 751 4.25 721, recast(area) lwidth(0) color(orange%10))
				(scatteri 0 733 0 735 4.25 735 4.25 733, recast(area) lwidth(0) color(gs12%50))
				(scatteri 4 740 "COVID-19", ms(i) mlabcolor("225 87 89") mlabpos(0) mlabsize(3)) 
				(scatteri 0 721 0 728 4.25 728 4.25 721, recast(area) lwidth(0) color(gs12%50))
				(scatteri 3.14 724.5 "No Data", ms(i) mlabcolor(gs3) mlabpos(0) mlabsize(2.25)) 
				(scatteri 2.86 724.5 "Available", ms(i) mlabcolor(gs3) mlabpos(0) mlabsize(2.25)) 
				(pcarrowi 3.75 751 3.75 721, lcolor("225 87 89") mcolor("225 87 89"))
				(pcarrowi 3.75 721 3.75 751, lcolor("225 87 89") mcolor("225 87 89"))
				(pcarrowi 3 726 3 728, lcolor(gs3) mcolor(gs3))
				(pcarrowi 3 723 3 721, lcolor(gs3) mcolor(gs3))
				(rarea lb ub date if female_js == 0, cmissing(n) fcolor("78 121 167%30") lwidth(0))
				(line mean date if female_js == 0, cmissing(n) lcolor("78 121 167"))
				(rarea lb ub date if female_js == 1, cmissing(n) fcolor("255 157 167%40") lwidth(0))
				(line mean date if female_js == 1, cmissing(n) lcolor("cranberry"))
				(scatteri 4.25 721 0 721, recast(line) lcolor(red%70))
				,
				legend(order(12 "Male" 14 "Female") size(2.5) row(1) col(2) span pos(6) ring(1) 
						region(fcolor(none) lcolor(none) lwidth(none) margin(l=15 t=-2 b=1))) 
				xlabel(709(2)751, labsize(1.5) format(%tmMon-YY) nogrid)
				xscale(noline)
				yscale(range(0 4.5))
				xtitle("")
				ylabel(0(1)4, nogrid)
				ytitle("% of" "job matches" "that applicants" "apply to", size(vsmall) orient(horizontal)) 
				title("{bf}Applied to Job Matches | By Gender",  pos(11) margin(b+3 t=-1) size(*.6)) 
				note("Unit of observation: One observation per job ad sent to jobseeker i." "The red vertical line indicates the emergence of Covid-19 in the country" "Activity of Matching people to jobs was paused in the 2nd Quarter of 2020" "This brief has comparisons from two time periods:" "      1) Pre vs Post COVID-19 which compares data between December '19 - January '20 and September '20 onwards and" "      2) during COVID-19 which compares data between September '20 - January '21 and February '21 - August '22." " " "Note that we did not collect data for some time after COVID-19 (highlighted in grey in the graph) due to" "lockdowns and an operational revamp while adapting to COVID-19." "Job Seekers: 8,980 | Matches: 847,157", size(*.75) margin(t+2))
				plotregion(margin(l=2.5 b=0 r=0 t=0))
				graphregion(margin(l=-3 r=10))
				scheme(white_tableau)
		;
		#delimit cr	
		
	
		* Saving the visual in PNG and EPS(Vector) format.
		graph export "./Results/application_rate.png", as(png) width(3840) replace
		graph export "./Results/application_rate.eps", as(eps) replace

